/**
 * Created by fangjiahui on 15/12/14.
 */

// 所有模块都通过 define 来定义
// header里面需要引入jquery
define(function (require, exports, module) {

    // 通过 require 引入依赖
    //default setting
    var _delayTime = 1000;
    var _closeFinish = true;
    var _redirectDelay = 3000;


    var Animate = {
        _self: this, //if target self
        successAnimate: function (animateLayer, delayTime, imageSrcLayer, targetGif, closeFinish, redirectUrl , redirectDelay) {
            closeFinish = closeFinish || _closeFinish;
            delayTime = delayTime || _delayTime;
            redirectDelay = redirectDelay || _redirectDelay;

            animateLayer.show();

            //clear src
            imageSrcLayer.attr('src', "");
            imageSrcLayer.attr('src', targetGif);


            setTimeout(function () {
                if (closeFinish) {
                    animateLayer.hide()
                }
                if (redirectUrl) {
                    setTimeout(function () {
                        window.location.href = redirectUrl
                    }, redirectDelay);
                }

            }, delayTime);
        },
    }


    // 通过 exports 对外提供接口
    //exports.doSomething = ...

    // 或者通过 module.exports 提供整个接口
    module.exports = Animate;

});